added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / VBWPFAnimationWhenDataChanged / My Project / MyExtensions / MyWpfExtension.vb
bloba00ea76b942c343e2c9e6992fc0014a1683dd048
1 #If _MyType <> "Empty" Then
3 Namespace My
4 ''' <summary>
5 ''' 用于定义“我的 WPF 命名空间”中的可用属性的模块
6 ''' </summary>
7 ''' <remarks></remarks>
8 <Global.Microsoft.VisualBasic.HideModuleName()> _
9 Module MyWpfExtension
10 Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer)
11 Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User)
12 Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows)
13 Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log)
14 ''' <summary>
15 ''' 返回正在运行的应用程序的应用程序对象
16 ''' </summary>
17 <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
18 Friend ReadOnly Property Application() As Application
19 Get
20 Return Global.System.Windows.Application.Current
21 End Get
22 End Property
23 ''' <summary>
24 ''' 返回有关主机计算机的信息。
25 ''' </summary>
26 <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
27 Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer
28 Get
29 Return s_Computer.GetInstance()
30 End Get
31 End Property
32 ''' <summary>
33 ''' 返回当前用户的信息。如果希望使用当前的
34 ''' Windows 用户凭据来运行应用程序,请调用 My.User.InitializeWithWindowsUser()。
35 ''' </summary>
36 <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
37 Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User
38 Get
39 Return s_User.GetInstance()
40 End Get
41 End Property
42 ''' <summary>
43 ''' 返回应用程序日志。可以使用应用程序的配置文件配置侦听器。
44 ''' </summary>
45 <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
46 Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log
47 Get
48 Return s_Log.GetInstance()
49 End Get
50 End Property
52 ''' <summary>
53 ''' 返回项目中定义的 Windows 集合。
54 ''' </summary>
55 <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
56 Friend ReadOnly Property Windows() As MyWindows
57 <Global.System.Diagnostics.DebuggerHidden()> _
58 Get
59 Return s_Windows.GetInstance()
60 End Get
61 End Property
62 <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Never)> _
63 <Global.Microsoft.VisualBasic.MyGroupCollection("System.Windows.Window", "Create__Instance__", "Dispose__Instance__", "My.MyWpfExtenstionModule.Windows")> _
64 Friend NotInheritable Class MyWindows
65 <Global.System.Diagnostics.DebuggerHidden()> _
66 Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T
67 If Instance Is Nothing Then
68 If s_WindowBeingCreated IsNot Nothing Then
69 If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then
70 Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.")
71 End If
72 Else
73 s_WindowBeingCreated = New Global.System.Collections.Hashtable()
74 End If
75 s_WindowBeingCreated.Add(GetType(T), Nothing)
76 Return New T()
77 s_WindowBeingCreated.Remove(GetType(T))
78 Else
79 Return Instance
80 End If
81 End Function
82 <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1822:MarkMembersAsStatic")> _
83 <Global.System.Diagnostics.DebuggerHidden()> _
84 Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T)
85 instance = Nothing
86 End Sub
87 <Global.System.Diagnostics.DebuggerHidden()> _
88 <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Never)> _
89 Public Sub New()
90 MyBase.New()
91 End Sub
92 <Global.System.ThreadStatic()> Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable
93 <Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Never)> Public Overrides Function Equals(ByVal o As Object) As Boolean
94 Return MyBase.Equals(o)
95 End Function
96 <Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Never)> Public Overrides Function GetHashCode() As Integer
97 Return MyBase.GetHashCode
98 End Function
99 <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1822:MarkMembersAsStatic")> _
100 <Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Never)> _
101 Friend Overloads Function [GetType]() As Global.System.Type
102 Return GetType(MyWindows)
103 End Function
104 <Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Never)> Public Overrides Function ToString() As String
105 Return MyBase.ToString
106 End Function
107 End Class
108 End Module
109 End Namespace
110 Partial Class Application
111 Inherits Global.System.Windows.Application
112 <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
113 <Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1822:MarkMembersAsStatic")> _
114 Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo
115 <Global.System.Diagnostics.DebuggerHidden()> _
117 Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly())
118 End Get
119 End Property
120 End Class
121 #End If